//
//  UIBarButtonItem+Extension.swift
//  YJWeiBo
//
//  Created by Jim1024 on 2017/1/16.
//  Copyright © 2017年 Jim1024. All rights reserved.
//

import UIKit

extension UIBarButtonItem {
    /// 扩展里面只能添加便利构造函数， 便利构造函数必须调用指定构造函数来创建对象
    convenience init(imageName: String, target: AnyObject?, action: Selector) {
        let button = UIButton()
        button.setImage(UIImage(named: imageName), for: .normal)
        button.setImage(UIImage(named: "\(imageName)_highlighted"), for: .highlighted)
        button.sizeToFit()
        button.addTarget(target, action: action, for: .touchUpInside)
        
        self.init(customView: button)
    }
}
